﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Best.SmartCms.CodeGeneration.Model;

namespace Best.SmartCms.CodeGeneration.BuiderFactory
{
    public abstract class CodeGenerationFactory
    {
        /// <summary>
        /// 输出路径
        /// </summary>
        public string OutPutPath { get; set; }

        /// <summary>
        /// 项目路径
        /// </summary>
        public string BasePath {
            get
            {
                var path= Environment.CurrentDirectory;
                if (string.IsNullOrEmpty(path)) return path;
                var index = path.IndexOf("Best.SmartCms.CodeGeneration", StringComparison.Ordinal);
                return index > 0 ? path.Remove(index) : path;
            }
        }

        public void Excute(CodeGenerationDto dto)
        {
            if (dto.ColumnFileds?.Count < 1)
            {
                return;
            }

            BuilderTemplate(dto);
        }

        public abstract void BuilderTemplate(CodeGenerationDto dto);
    }
}
